public class EventItem {
    private long endDate;
    private String eventName;
    private String eventContent;
    private boolean longTermEvent;
    private boolean outOfDate;

    public EventItem(String readFormatLine) {
        String[] tokens = readFormatLine.split("&");
        if (tokens.length != 4) {
            System.out.println("EventItem Error! readFormatLine没有4个字段!");
        } else {
            this.endDate = Long.parseLong(tokens[0]);
            this.eventName = tokens[1];
            this.eventContent = tokens[2];
            this.longTermEvent = Boolean.parseBoolean(tokens[3]);
        }
        OnlyDate date = new OnlyDate();
        this.outOfDate = date.isBiggerThan(this.endDate);
    }

    public boolean isOutOfDate() {
        return this.outOfDate;
    }

    public void setAsOutOfDate() {
        this.outOfDate = true;
    }

    public void changeInfo(long endDate, String eventName, String eventContent, boolean isLongTermEvent) {
        this.endDate = endDate;
        this.eventName = eventName;
        this.eventContent = eventContent;
        this.longTermEvent = isLongTermEvent;

        this.outOfDate = this.endDate < OnlyDate.getDate();
    }

    public long getEndDate() {
        return endDate;
    }

    public String getEventName() {
        return eventName;
    }

    public String getEventContent() {
        return eventContent;
    }

    public boolean isLongTermEvent() {
        return longTermEvent;
    }

    public String getWriteFormat() {
        return this.endDate + "&" + this.eventName + "&" + this.eventContent + "&" + this.longTermEvent + "\n";
    }
}
